<include file="Public:header_new"/>
<div class="usernewout">
	<div class="usncont">
		<!--左侧菜单-->
		<include file="User:left"/>
		<!--左侧菜单-->
		<!--上方导航-->
		<include file="User:nav"/>
		<!--上方导航-->
		<div class="usnc_right">
			<div class="nameauth">
			  <h1><if condition="$paypwd eq 0">{$Think.lang.Login_szjymm} <else />{$Think.lang.g_modify_tradepwd} </if></h1>
			 <!--  <div style="color:#059ff5;text-align: center;margin-top: 20px;">{$Think.lang.g_paypwd_notice} </div> -->
			  <div class="rech_top" style="width: 600px;">
				  <div class="rech_box">
					  <div class="rech_bd safe_rech_bd">
						  <ul>
							  <li>
								  <div class="rechmid" style="width:600px;">
								  <if condition="$paypwd eq 0">
									  <div class="rechipt_box" style="display:none;">
										  <label> {$Think.lang.g_paypwd}{$Think.lang.sTrade_index_cnmh}</label>
										  <div class="iptbox">
											  <input type="password" class="rechipt" id="oldpaypassword" placeholder="" onkeyup="chkpwd();" maxlength="16"/>
										  </div>
									  </div>

									  <div class="rechipt_box">
										  <label>{$Think.lang.g_paypwd}{$Think.lang.sTrade_index_cnmh}</label>
										  <div class="iptbox">
											  <input type="password" id="newpaypassword" class="rechipt" placeholder="{$Think.lang.User_sixbyte}" onblur="if(this.placeholder == '')this.placeholder='{$Think.lang.User_sixbyte}';" onclick="if(this.placeholder == '{$Think.lang.User_sixbyte}')this.placeholder='';" onkeyup="chknewpwd();" maxlength="16"/>
										  </div>
									  </div>

									  <div class="rechipt_box">
										  <label>{$Think.lang.g_pwd_queren}{$Think.lang.sTrade_index_cnmh}</label>
										  <div class="iptbox">
											  <input type="password" id="repaypassword" class="rechipt" placeholder="{$Think.lang.User_sixbyte}" onblur="if(this.placeholder == '')this.placeholder='{$Think.lang.User_sixbyte}';" onclick="if(this.placeholder == '{$Think.lang.User_sixbyte}')this.placeholder='';" onkeyup="rechknewpwd();" maxlength="16"/>
										  </div>
									  </div>
									<else />
									  <div class="rechipt_box">
										  <label>{$Think.lang.g_paypwd}{$Think.lang.sTrade_index_cnmh}</label>
										  <div class="iptbox">
											  <input type="password" class="rechipt" id="oldpaypassword" placeholder="" onkeyup="chkpwd();" maxlength="16"/>
										  </div>
									  </div>

									  <div class="rechipt_box">
										  <label>{$Think.lang.g_paypwd_new}{$Think.lang.sTrade_index_cnmh}</label>
										  <div class="iptbox">
											  <input type="password" id="newpaypassword" class="rechipt" placeholder="{$Think.lang.User_sixbyte}" onblur="if(this.placeholder == '')this.placeholder='{$Think.lang.User_sixbyte}';" onclick="if(this.placeholder == '{$Think.lang.User_sixbyte}')this.placeholder='';" onkeyup="chknewpwd();" maxlength="16"/>
										  </div>
									  </div>

									  <div class="rechipt_box">
										  <label>{$Think.lang.g_paypwd_new_confim}{$Think.lang.sTrade_index_cnmh}</label>
										  <div class="iptbox">
											  <input type="password" id="repaypassword" class="rechipt" placeholder="{$Think.lang.User_sixbyte}" onblur="if(this.placeholder == '')this.placeholder='{$Think.lang.User_sixbyte}';" onclick="if(this.placeholder == '{$Think.lang.User_sixbyte}')this.placeholder='';" onkeyup="rechknewpwd();" maxlength="16"/>
										  </div>
									  </div>
									</if>
									<div class="rechipt_box">
										<label>{$Think.lang.g_yx_verify}{$Think.lang.sTrade_index_cnmh}</label>
										  <div class="iptbox">
											  <input type="text" id="email_verify" value="" class="rechipt halfipt" maxlength="6" />
											  <input type="button" id="regBtn" onclick="EmCode()" value="{$Think.lang.g_yx_rec_verify} " class="yzmbut">
												<if condition="$user['email'] eq '' || $user['email'] eq null">
												<p class="attention">{$Think.lang.g_pwd_no_bindyx}</p>
												<else />
												<p class="attention">* {$Think.lang.g_pwd_yx_recode} {$user['email']}</p>
												</if>
										  </div>
									</div>
									<div class="dv_submit">
										<input type="button" id="btn-submit" value="{$Think.lang.User_save}" title="{$Think.lang.User_save} " onclick="Update()" />
									</div>
								  </div>
							  </li>
						  </ul>
					  </div>
				  </div>
			  </div>
		  </div>
	  </div>
	</div>
</div>
<script type="text/javascript">
  $('input').focus(function(){
    var t=$(this);
    if(t.attr('type')=='text'||t.attr('type')=='password')
      t.css({'box-shadow' : '0px 0px 3px #20212d','border' : '1px solid #20212d','color' : '#99A6BF' });
    if(t.val()==t.attr('placeholder'))
      t.val('');
  });
  $('input').blur(function(){
    var t=$(this);
    if(t.attr('type')=='text'||t.attr('type')=='password')
      t.css({'box-shadow' : 'none','border' : '1px solid #20212d','color' : '#99A6BF' });
    if(t.attr('type')!='password'&&!t.val())
      t.val(t.attr('placeholder'));
  });

  function EmCode() {
  layer.load(0, {shade: [0.5,'#8F8F8F']});
    $('#regBtn').attr("disabled", "disabled");
    $.post("{:U('Verify/paypwdemail')}", {}, function (data) {
    layer.closeAll();
      if (data.status == 1) {
        layer.msg(data.info, {
          icon: 1
        });
        var obj = $('#regBtn');
        var wait = 120;
        var interval = setInterval(function () {
          obj.css('backgroundColor', '#135f91');
          obj.val(wait + '{$Think.lang.Finance_again}');
          wait--;
          if (wait < 0) {
            obj.removeAttr("disabled");
            clearInterval(interval);
            obj.val('{$Think.lang.Finance_hqyzm2} ');
            obj.css('backgroundColor', '#135f91');
          }
          ;
        }, 1000);
      } else {
        $('#regBtn').removeAttr("disabled");
        layer.msg(data.info, {
          icon: 2
        });
      }
    }, "json");
}


  function Update(){
    var repaypassword = $("#repaypassword").val();
    var newpaypassword = $("#newpaypassword").val();
    var oldpaypassword = $("#oldpaypassword").val();
    var email_verify = $("#email_verify").val();
    var paypwd={$paypwd};

    if (paypwd == 1 && (oldpaypassword == "" || oldpaypassword == null)) {
      layer.tips('{$Think.lang.Bazaar_srjypw} ', '#oldpaypassword', {
        tips: 3
      });
      return false;
    }

    if (newpaypassword == "" || newpaypassword == null) {
      layer.tips('{$Think.lang.User_srnewjypw} ', '#newpaypassword', {
        tips: 3
      });
      return false;
    }

     if (repaypassword == "" || repaypassword == null) {
      layer.tips('{$Think.lang.User_srenterpw} ', '#repaypassword', {
        tips: 3
      });
      return false;
    }
	layer.load(0, {shade: [0.5,'#8F8F8F']});
    $.post("{:U('User/uppaypassword')}",{oldpaypassword : oldpaypassword,newpaypassword : $('#newpaypassword').val(),repaypassword : $('#repaypassword').val(),email_verify: email_verify},function(data){
		layer.closeAll();
      if(data.status==1){
        layer.msg(data.info,{icon : 1 });
        window.location="{:U('User/paypassword')}";
      }else{
        layer.msg(data.info,{icon : 2 });
        if(data.url){
          window.location=data.url;
        }
      }
    },"json");
  }

	function chkpwd(){
		var paypassword = $("#oldpaypassword").val();
		var patten =/^[a-zA-Z0-9]+$/;
		var match = new RegExp(patten);
		if (!match.test(paypassword)) {
			layer.tips('{$Think.lang.code_format} ','#oldpaypassword',{tips:3});
			var result = paypassword.substring(0,paypassword.length-1);
			$("#oldpaypassword").val(result);
		}
	}
	function chknewpwd(){
		var newpaypassword = $("#newpaypassword").val();
		var patten =/^[a-zA-Z0-9]+$/;
		var match = new RegExp(patten);
		if (!match.test(newpaypassword)) {
			layer.tips('{$Think.lang.code_format}','#newpaypassword',{tips:3});
			var result = newpaypassword.substring(0,newpaypassword.length-1);
			$("#newpaypassword").val(result);
		}
	}
	function rechknewpwd(){
		var repaypassword = $("#repaypassword").val();
		var patten =/^[a-zA-Z0-9]+$/;
		var match = new RegExp(patten);
		if (!match.test(repaypassword)) {
			layer.tips('{$Think.lang.code_format}','#repaypassword',{tips:3});
			var result = repaypassword.substring(0,repaypassword.length-1);
			$("#repaypassword").val(result);
		}
	}
	function chkyzm(){
		var mobile_verify = $("#mobile_verify").val();
		if(!mobile_verify){
			layer.tips('{$Think.lang.User_txdxyzm} ','#mobile_verify',{tips:3});
			return false;
		}
	}
	//菜单高亮
$('#user_index').addClass('on');
</script>

<include file="Public:footer_new"/>